﻿<!DOCTYPE html>
<html>
<head>
    <title>JS Conditional Exercise 2</title>
    <link href="styles/js-console.css" rel="stylesheet" />
</head>
<body>
    <h1>Shows the sign (+ or -) of the product of three real numbers without calculating it</h1>
    <div>
        <label for="num1">Number 1:</label>
        <input type="number" id="num1" />
        <label for="num2">Number 2:</label>
        <input type="number" id="num2" />
        <label for="num3">Number 3:</label>
        <input type="number" id="num3" />
        <button onclick="execute()">Execute</button>
    </div>
    <div id="js-console"></div>
    <script src="scripts/js-console.js"></script>
    <script>
        function execute()
        {
            var num1 = jsConsole.readFloat("#num1");
            var num2 = jsConsole.readFloat("#num2");
            var num3 = jsConsole.readFloat("#num3");
            var numberMinus = 0;

            // If three numbers are 0 '+' will be shown

            if (num1 < 0)
            {
                numberMinus++;
            }
            if (num2 < 0)
            {
                numberMinus++;
            }
            if (num3 < 0)
            {
                numberMinus++;
            }

            if ((numberMinus % 2) != 0)
            {
                jsConsole.writeLine("Product sign is '-'");
            }
            else
            {
                jsConsole.writeLine("Product sign is '+'");
            }
        }
    </script>
</body>
</html>
